<!DOCTYPE html>
<html lang="zh-cn">
    <head>
        <meta charset="UTF-8"/>
        <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
        <title>Document</title>
        <link rel="stylesheet" href="elementUI/theme-default/index.css" />
    </head>
    <body>
        <div id="app">
            <template>
                <div>
                    <el-table ref="singleTable" :data="tableData" stripe border highlight-current-row @current-change="handleCurrentChange" height="250" width="100%">
                        <el-table-column type="index" width="50"></el-table-column>
                        <el-table-column prop="userID" label="用户ID" width="180"></el-table-column>
                        <el-table-column prop="addDate" label="加黑时间" width="180"></el-table-column>
                        <el-table-column prop="removeDate" label="解禁时间" width="180"></el-table-column>
                        <el-table-column prop="operate" label="操作" width="180">
                            <template scope="scope">
                                <el-button @click.native.prevent="deleteRow(scope.$index, tableData)" type="text" size="small">解禁该用户</el-button>
                            </template>
                            <!-- <template scope="scope">
                                <el-button
                                  @click.native.prevent="deleteRow(scope.$index, tableData4)"
                                  type="text"
                                  size="small">
                                  移除
                                </el-button>
                            </template> -->
                        </el-table-column>
                    </el-table>
                    <div style="margin-top:20px">
                        <el-button @click="setCurrent(tableData[1])">选中第二行</el-button>
                        <el-button @click="setCurrent()">取消选择</el-button>
                    </div>
                </div>
            </template>
        </div>
        <script src="js/vue.js"></script>
        <script src="elementUI/index.js"></script>
        <script>
            new Vue({
                el:"#app",
              data() {
                return {
                  tableData: [{
                    userID:'456789054611',
                    addDate: '2017-03-28 20:43:01',
                    removeDate: '2017-03-30 20:43:01',
                    operate: '解禁该用户'
                  }, {
                    userID:'456789054612',
                    addDate: '2017-03-28 20:43:01',
                    removeDate: '2017-03-30 20:43:01',
                    operate: '解禁该用户'
                  }, {
                    userID:'456789054613',
                    addDate: '2017-03-28 20:43:01',
                    removeDate: '2017-03-30 20:43:01',
                    operate: '解禁该用户'
                  }, {
                    userID:'456789054614',
                    addDate: '2017-03-28 20:43:01',
                    removeDate: '2017-03-30 20:43:01',
                    operate: '解禁该用户'
                  }],
                  currentRow:null
                }
              },
              methods:{
                deleteRow:function(index,rows){
                    rows.splice(index,1);
                },
                setCurrent:function(row){
                    this.$refs.singleTable.setCurrentRow(row);
                },
                // handleCurrentChange:function(val){
                //     this.currentRow=val;
                // },
                handleCurrentChange(val){
                    this.currentRow=val;
                }
              }
            });
        </script>
    </body>
</html>